package com.cy.pj.goods.dao;

import com.cy.pj.goods.pojo.Goods;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class GoodsDaoImpl implements GoodsDao{
    @Autowired
    private SqlSession sqlSession;

    @Override
    public List<Goods> findGoods() {
        System.out.println("=======");
        String statement="com.cy.pj.goods.dao.GoodsDao.findGoods";
        List<Goods> list=sqlSession.selectList(statement);
        return list;
    }

    @Override
    public int deleteById(Integer id) {
        long t1=System.currentTimeMillis();
        int rows=sqlSession.delete("com.cy.pj.goods.dao.GoodsDao.deleteById");
        long t2=System.currentTimeMillis();
        return rows;
    }

    @Override
    public int deleteObject(Integer... ids) {
        String statement="com.cy.pj.goods.dao.GoodsDao.deleteObject";
        Map<String,Object>map=new HashMap<>();
        map.put("ids", ids);
        return sqlSession.delete(statement,map);
    }
}
